<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4" xmlns:sec="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">

    <title>在线考试系统</title>
    <meta content="" name="descriptison">
    <meta content="" name="keywords">

    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">

    <!-- Vendor CSS Files -->
    <link th:href="@{/static/front/assets/vendor/bootstrap/css/bootstrap.min.css}"  rel="stylesheet">
    <link  rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}">
    <link th:href="@{/static/front/assets/vendor/icofont/icofont.min.css}"  rel="stylesheet">
    <link th:href="@{/static/front/assets/vendor/boxicons/css/boxicons.min.css}"  rel="stylesheet">
    <link th:href="@{/static/front/assets/vendor/animate.css/animate.min.css}"  rel="stylesheet">
    <link th:href="@{/static/front/assets/vendor/remixicon/remixicon.css}"  rel="stylesheet">
    <link th:href="@{/static/front/assets/vendor/owl.carousel/assets/owl.carousel.min.css}"  rel="stylesheet">
    <link th:href="@{/static/front/assets/vendor/venobox/venobox.css}"  rel="stylesheet">
    <link th:href="@{/static/front/assets/vendor/aos/aos.css}"  rel="stylesheet">

    <!-- Template Main CSS File -->
    <link th:href="@{/static/front/assets/css/style.css}"  rel="stylesheet">

    <!--对话框-->
    <link rel="stylesheet" th:href="@{/static/js/jconfirm/jquery-confirm.min.css}">

    <link href="css/materialdesignicons.min.css" rel="stylesheet" th:href="@{/static/css/materialdesignicons.min.css}">
    <link href="css/style.min.css" rel="stylesheet" th:href="@{/static/css/style.min.css}">
    <!-- bootstrap表格-->
    <link rel="stylesheet" th:href="@{/static/js/bootstrap-table/bootstrap-table.min.css}">

</head>

<body style="background-color: #97b6d0">




<!-- ======= Header ======= -->
<header id="header" class="fixed-top ">
    <div class="container d-flex align-items-center">

        <h1 class="logo mr-auto"><a href="#header" class="scrollto">在线考试网</a></h1>

        <nav class="nav-menu d-none d-lg-block">
            <ul>
                <li class="active"><a href="/Front/index">首页</a></li>
                <li><a href="/StuUser/queryScorePage">查询成绩</a></li>
                <li><a href="/StuUser/queryAllScorePage">查询全科目成绩</a></li>
                <!--          从  session.setAttribute("stuUser",stu);-->
                <li th:if="${session.stuUser==null}" ><a th:href="@{/Front/login}">登录</a></li>
                <li th:if="${session.stuUser!=null}"><a th:href="@{/StuUser/logOut}">退出</a></li>
            </ul>
        </nav><!-- .nav-menu -->

    </div>
</header><!-- End Header -->

<!-- ======= Hero Section ======= -->
<section id="hero" class="d-flex justify-cntent-center align-items-center">
    <div id="heroCarousel" class="container carousel carousel-fade" data-ride="carousel">

        <!-- Slide 1 -->
        <div class="carousel-item active">
            <div class="carousel-container">
                <h2 class="animated fadeInDown">欢迎使用 <span>在线考试系统 选择试卷开始考试</span></h2>
                <p class="animated fadeInUp"></p>
            </div>
        </div>

        <a class="carousel-control-prev" href="#heroCarousel" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon bx bx-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>

        <a class="carousel-control-next" href="#heroCarousel" role="button" data-slide="next">
            <span class="carousel-control-next-icon bx bx-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>

    </div>
</section><!-- End Hero -->

<main id="main" >

    <!-- ======= Icon Boxes Section ======= -->点击
    <section id="icon-boxes" class="icon-boxes" style="margin-top:20px">
    </section><!-- End Icon Boxes Section -->
    <div class="container container-fluid" >

        <div class="row" style="margin-top:20px">

            <!--          <div th:each="paper : ${papers}" class="col-md-6 col-lg-3 d-flex align-items-stretch mb-5 mb-lg-0" style="padding-bottom: 20px" data-aos="fade-up" >-->
            <!--            <div class="icon-box">&lt;!&ndash;th:src="@{/static/front/assets/icon/paper.png}"&ndash;&gt;-->
            <!--              <div class="icon"><img th:src="@{/static/front/assets/icon/paper.png}"/></div>-->
            <!--              <h4 class="title"><a href=""><span th:text="${paper.name}"></span></a></h4>-->
            <!--              <p class="description">开始时间 <span th:text="${#dates.format(paper.startTime,'yyyy-MM-dd HH:mm')}"></span></p>-->
            <!--			  <p class="description">结束时间 <span th:text="${#dates.format(paper.endTime,'yyyy-MM-dd HH:mm')}"></span></p>-->
            <!--				<div class="entry-content read-more" style="text-align:center;margin-top:10px">-->
            <!--                  <button type="button" class="btn btn-warning" style="color:white;" th:onclick="examPaper([[${paper}]])">开始测试</button>-->
            <!--                </div>-->
            <!--            </div>-->
            <!--          </div>-->

            <div class="col-lg-12">

                <div style="display:flex">
                    <!-- 查询搜索框start-->
                    <label class="myLabel-content" style="line-height: 40px">试卷名称：</label>
                    <input type="text" class="form-control" name="name" id="q_name" style="width: 160px;height: 40px"/>


                    <label class="myLabel-content" style="line-height: 40px;margin-left: 10px">试卷编号：</label>
                    <input type="text" class="form-control" name="name" id="q_id" style="width: 160px;height: 40px"/>
                    <button id="search" type="button" class="btn btn-primary"  style="height: 40px;margin-left: 10px"  data-method="search">

                        <i class="mdi mdi-account-search"></i>搜索</button>
                </div>
                <div class="table-responsive">
                    <table id="indexPaperTable" ></table>
                </div>

                <!-- 查询搜索框end-->

            </div>


        </div>


        <!-- ======= About Us Section ======= -->
</main>




<!-- ======= Footer ======= -->
<footer id="footer">

    <div class="footer-newsletter">
        <div class="container">
            <div class="row">
                <div class="col-lg-6">
                    <h4></h4>
                    <p></p>
                </div>
                <div class="col-lg-6">

                </div>
            </div>
        </div>
    </div>

    <div class="footer-top">
        <div class="container">
            <div class="row">

                <div class="col-lg-4 col-md-6 footer-links">
                    <h4>用户连接</h4>
                    <ul>
                        <li><i class="bx bx-chevron-right"></i> <a href="#">在线考试网</a></li>
                        <li><i class="bx bx-chevron-right"></i> <a href="#">项目分享圈</a></li>
                        <li><i class="bx bx-chevron-right"></i> <a href="#">学习交流圈</a></li>
                    </ul>
                </div>

                <div class="col-lg-4 col-md-6 footer-links">
                    <h4>我们理念</h4>
                    <ul>
                        <li>开放</li>
                        <li>创新</li>
                        <li>共赢</li>
                    </ul>
                </div>

                <div class="col-lg-4 col-md-6 footer-links">
                    <h4>联系方式</h4>
                    <ul>
                        <li>QQ:3393857689</li>
                        <li>email:3393857689@163.com</li>
                        <li>tel:10000000000</li>
                    </ul>
                </div>



            </div>
        </div>
    </div>

    <div class="container">
        <div class="copyright">
            &copy; Copyright <strong><span>xxx</span></strong>. All Rights Reserved
        </div>

    </div>
</footer><!-- End Footer -->

<a href="#" class="back-to-top"><i class="ri-arrow-up-line"></i></a>
<div id="preloader"></div>

<!-- Vendor JS Files -->
<script th:src="@{/static/front/assets/vendor/jquery/jquery.min.js}"></script>
<script th:src="@{/static/front/assets/vendor/bootstrap/js/bootstrap.bundle.min.js}" ></script>
<script th:src="@{/static/front/assets/vendor/jquery.easing/jquery.easing.min.js}" ></script>
<script th:src="@{/static/front/assets/vendor/php-email-form/validate.js}" ></script>
<script th:src="@{/static/front/assets/vendor/owl.carousel/owl.carousel.min.js}"></script>
<script th:src="@{/static/front/assets/vendor/venobox/venobox.min.js}"></script>
<script th:src="@{/static/front/assets/vendor/isotope-layout/isotope.pkgd.min.js}"></script>
<script th:src="@{/static/front/assets/vendor/aos/aos.js}"></script>
<script type="text/javascript"  th:src="@{/static/js/jconfirm/jquery-confirm.min.js}"></script>
<!-- Template Main JS File -->
<script th:src="@{/static/front/assets/js/main.js}"></script>

<!-- bootstrap表格-->
<script type="text/javascript" src="js/bootstrap.min.js" th:src="@{/static/js/bootstrap.min.js}"></script>
<script type="text/javascript"  th:src="@{/static/js/bootstrap-table/bootstrap-table.min.js}"></script>
<script type="text/javascript"  th:src="@{/static/js/bootstrap-table/bootstrap-table-zh-CN.js}"></script>
<script type="text/javascript"  th:src="@{/static/js/my-form.js}"></script>
<script type="text/javascript"  th:src="@{/static/js/my-ajax.js}"></script>
<script type="text/javascript"  th:src="@{/static/js/confirm.js}"></script>

<script type="text/javascript" th:inline="javascript">
    var ctxPath = [[${#httpServletRequest.getContextPath()}]];

    let stuUser = '[[${session.stuUser}]]'
    if ( !stuUser ){  //没有登录
        window.location = '/ExamAPP/Front/login';
    }

    /**
     * 弹出学生测试试卷
     *  (1)判断当前在首页是否已经登录过 如果登录过 才能做操作
     *  (2)登录过，点击试卷的时候，判断考试是否匹配（考试时间是否已经结束）
     *  (3)上面的条件都满足时候，弹出测试页面  --进行测试
     */
    function examPaper(paper){
        //从session里面查看是否有登录用户
        let stuUser = '[[${session.stuUser}]]'
        console.log(stuUser)
        if ( !stuUser ){ //没有登录
            window.location = ctxPath +'/Front/login';
            return;
        }
        //登录成功
        //判断时间是否匹配，小于开始时间，大于结束时间都是无效时间
        let currentTime = new Date();
        if(currentTime < new Date(paper.startTime)){
            confirmFail( '测试时间还没有到' );
            return;
        }
        if(currentTime > new Date(paper.endTime)){
            confirmOK('考试已经结束');
            return;
        }
        //有效时间之内
        //弹出试卷 开始考试 --考试页面和之前预览页类似 都要展示试卷里面的试题，paperId参数传到后台
        window.location = ctxPath +"/Exam/popPaper/"+ paper.id;
    }
</script>
<script type="text/javascript">

    $(document).ready(
        function( e ){
            $('#indexPaperTable').bootstrapTable({
                url: ctxPath +'/Front/paperIndex/listPage',                      //请求后台的URL（*）
                method: 'GET',                      //请求方式（*）
                //toolbar: '#toolbar',              //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否显示分页（*）
                sortable: true,                     //是否启用排序
                sortOrder: "asc",                   //排序方式
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                      //初始化加载第一页，默认第一页,并记录
                pageSize: 10,                     //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                search: false,                      //是否显示表格搜索
                strictSearch: true,
                showRefresh: true,                  //是否显示刷新按钮
                minimumCountColumns: 2,             //最少允许的列数
                clickToSelect: true,                //是否启用点击选中行
                //height: 500,                      //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                uniqueId: "id",                     //每一行的唯一标识，一般为主键列
                showToggle: true,                   //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,                  //是否显示父子表
                singleSelect: true, //开启单选,想要获取被选中的行数据必须要有该参数
                queryParams : function(params) {//上传服务器的参数
                    var temp = {
                        page: (params.offset / params.limit) + 1,// SQL语句起始索引
                        limit: params.limit,  // 每页显示数量
                        name: $("#q_name").val() // 获取到搜索时输入的name值，传到后台
                    };
                    return temp;//返回后台查询到的数据 offset  （row）page name  然后按照以下表格的列columns进行展示。试卷编号试卷名称试卷等级等等，，，
                },
                columns: [
                    {
                        align : 'center',
                        radio: true
                    },{
                        field: 'id',
                        title: '试卷编号'
                    }, {
                        field: 'name',
                        title: '试卷名称'
                    }, {
                        field: 'startTime',
                        title: '开始时间'
                    }, {
                        field: 'endTime',
                        title: '结束时间'
                    },
                    {
                        field: 'doOpt',
                        title: '操作',
                        formatter : optFormatter  //调用optFormatter方法进行格式化
                    }]
            });

            //操作格式化 examPaper([[${paper}]])  点击调用方法onclick=\'edit("' + row.id + '") onclick="del(\''+row.id+'\')"把id传到后台，根据选中的id进行删除
            function optFormatter(value,row, index){
                let jsonStr = JSON.stringify(row)
                var c = '<a class="btn btn-xs btn-default" href="#!"  onclick=\'examPaper('+ jsonStr+')\' title="开始考试" data-toggle="tooltip">开始测试<i class="mdi mdi-pencil"></i></a>';
                return c  ;
            }
            //绑定事件
            $("button,a").on('click',function(){
                //获取到 a标签里面配置 data-method
                var methodName = $(this).data('method');
                if(methodName){
                    doMethod[methodName]();
                }
            });

            var doMethod = {
                search:function(){
                    var name = $("#q_name").val();
                    var id = $("#q_id").val()
                    var queryparam = {
                        silent:true,
                        query:{
                            name:name,
                            id:id
                        }
                    };
                    $('#indexPaperTable').bootstrapTable('refresh',queryparam);

                }
            }

        })

</script>

</body>

</html>